from datetime import date
from pydantic import BaseModel
from typing import List, Union

from choices.choices import DoctorAbsent


class User(BaseModel):
    username: str
    email: Union[str, None] = None
    full_name: Union[str, None] = None
    disabled: Union[bool, None] = None


class UserInDB(User):
    hashed_password: str


class UserCreate(BaseModel):
    username: str
    login: str
    password: str
    role_id: int
    modality_id: int = None
    employment_rate: str = None
    start_work: date = None
    status: str = None


class UserOut(BaseModel):
    id: int
    username: str
    login: str


class UserUpdate(BaseModel):
    username: str = None
    modality_id: int = None
    additional_modality: List[int] = None
    employment_rate: str = None
    start_work: date = None
    status: str = None


class UserAbsent(BaseModel):
    reason: DoctorAbsent
    start_absent: date
    quantity_days: int


class ForecastSchema(BaseModel):
    id_filename: int
    date: date
    week: int
    wc: int
    modality: str
    type: str
    kind: str
    number: int
    workhours: int

    class Config:
        orm_mode = True
        json_encoders = {
            date: lambda v: v.strftime("%Y-%m-%d"),
        }


class TaskForecast(BaseModel):
    statistics_filename: str
    forecast_name: str


class TaskSchedule(BaseModel):
    schedule_name: str
    forecast_id: int
    date_start_schedule: str
